package capaGrafica;

import java.io.Serializable;

public class Fecha implements Serializable, Comparable<Fecha>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private int anio;
	private int mes;
	private int dia;
	
	public Fecha(int anio,int mes,int dia){
		
		this.setAnio(anio);
		this.setMes(mes);
		this.setDia(dia);
		
	}

	public int getAnio() {
		return anio;
	}

	public void setAnio(int anio) {
		this.anio = anio;
	}

	public int getMes() {
		return mes;
	}

	public void setMes(int mes) {
		this.mes = mes;
	}

	public int getDia() {
		return dia;
	}

	public void setDia(int dia) {
		this.dia = dia;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + anio;
		result = prime * result + dia;
		result = prime * result + mes;
		return result;
	}

	

	
	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Fecha other = (Fecha) obj;
		if (anio != other.anio) {
			return false;
		}
		if (dia != other.dia) {
			return false;
		}
		if (mes != other.mes) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		String ret = "";
		ret = + dia +"/"+ mes +"/"+ anio  ;
		return ret;
	}

	@Override
	public int compareTo(Fecha o) {
		int ret;
		if(this.dia > o.dia || this.mes > o.mes || this.anio > o.anio){
			ret = 1;
		}else if(this.dia < o.dia || this.mes < o.mes || this.anio < o.anio){
			ret = -1;
		}else{
			ret = 0;
		}
		return ret;
	}

	
	

}
